#include "create_ohos_peerconnection_factory.h"
#include "ohos_peer_connection_factory.h"
#include "ohos_media_constraints.h"
#include "pc/video_track_source_proxy.h"

namespace webrtc {

rtc::scoped_refptr<ohoswebrtc::OHOSPeerConnectionFactoryInterface> CreateOHOSPeerConnectionFactory() {
  auto pc_factory = rtc::scoped_refptr<ohoswebrtc::OHOSPeerConnectionFactoryInterface>(
    ohoswebrtc::OHOSPeerConnectionFactory::Create());
  return pc_factory;
}

RTC_EXPORT rtc::scoped_refptr<ohoswebrtc::OHOSMediaConstraintsInterface> CreateOHOSMediaConstraints(std::map<std::string, std::string> mandatory, std::map<std::string, std::string> optional) {
  auto media_contraints = rtc::scoped_refptr<ohoswebrtc::OHOSMediaConstraintsInterface>(
    ohoswebrtc::OHOSMediaConstraints::Create(mandatory, optional));
  return media_contraints;
}

RTC_EXPORT rtc::scoped_refptr<ohoswebrtc::OHOSVideoTrackSourceAdapter> CreateVideoSourceTrackAdapter(bool is_screen_cast) {
  auto video_source_adapter = rtc::scoped_refptr<ohoswebrtc::OHOSVideoTrackSourceAdapter>(
    ohoswebrtc::OHOSVideoTrackSourceAdapter::Create(is_screen_cast));
  return video_source_adapter;
}

RTC_EXPORT ohoswebrtc::OHOSVideoTrackSourceAdapter *GetVideoSourceTrackAdapter(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> video_track_source) {
  webrtc::VideoTrackSourceProxy *proxy_source =
      static_cast<webrtc::VideoTrackSourceProxy *>(video_track_source.get());
  ohoswebrtc::OHOSVideoTrackSourceAdapter *video_track_source_adapter = static_cast<ohoswebrtc::OHOSVideoTrackSourceAdapter *>(proxy_source->internal());
  return video_track_source_adapter;
}


}